﻿#pragma once

#include "smmtype.h"

// 유니코드
extern size_t conv_asc_to_uni(wchar_t* outuni, size_t outsize, const char* inasc, size_t insize);
extern size_t conv_uni_to_asc(char* outasc, size_t outsize, const wchar_t* inuni, size_t insize);
extern size_t get_uni(wchar_t* outuni, size_t outsize, const char* inasc);
extern size_t get_asc(char* outasc, size_t outsize, const wchar_t* inuni);

extern size_t conv_utf8_to_ucs4(DWORD* dest, size_t destsize, const char* src, size_t srclen);
extern size_t conv_utf8_to_utf16(wchar_t* dest, size_t destsize, const char* src, size_t srclen);
extern size_t conv_utf16_to_utf8(char* dest, size_t destsize, const wchar_t* src, size_t srclen);
extern size_t conv_utf16_to_ucs4(DWORD* dest, size_t destsize, const wchar_t* src, size_t srclen);
extern size_t conv_ucs4_to_utf8(char* dest, size_t destsize, const DWORD* src, size_t srclen);
extern size_t conv_ucs4_to_utf16(wchar_t* dest, size_t destsize, const DWORD* src, size_t srclen);

// UTF-8
extern char* utf8_find_char_prev(const char* s, const char* p);
extern char* utf8_find_char_next(const char* s, const char* end);
extern char* utf8_char_prev(const char* s);
extern char* utf8_char_next(const char* s);
extern DWORD utf8_ccnc(const char* p);
extern int utf8_cunc(DWORD c, char* out);
extern size_t utf8_len(const char* s);

// 매액스
extern void SplitPath(const MCHAR *path, char *dir, int dir_len, char *filename, int filename_len);
extern int ConvTexStageToSMM(int type);
extern bool TestIsBiped(IGameNode *node);
extern GMatrix CheckGmTm(const GMatrix& org, bool* isparity = nullptr);
extern void CheckGmDecompose(const GMatrix& g, Vec3* loc, Quat4* rot, Vec3* scl);
extern GMatrix CheckGmTranspose(const GMatrix& org);
extern Mat4 ConvGmToMat4(const GMatrix& g);
extern bool ConvertPropToValue(IGameProperty* prop, Point3& pt);
extern bool ConvertPropToValue(IGameProperty* prop, float& f);
extern FrmType ConvObjTypeToFrmType(IGameNode* node, IGameObject::ObjectTypes objtype);
extern int CalcPercent(size_t now, size_t max);
extern bool ConvNameToSMM(char* dest, size_t size, const MCHAR *inputsrc);

//
template<size_t SIZE>
bool ConvNameToSMM(char(&dest)[SIZE], const MCHAR *inputsrc)
{
	return ConvNameToSMM(dest, SIZE, inputsrc);
}
